import { getHeight } from '../../utils/util'
Page({
  data: {
    goodsList: [],
    goodsListLoadStatus: 0,
    pageLoading: false,
    oneList: [
      { title: '专家工作坊', img: '/image/service/b_gongzuofang.png', active: true, aimg: '/image/service/b_gongzuofang_a.png' },
      { title: '朋辈交流站', img: '/image/service/b_jiaoliu.png', aimg: '/image/service/b_jiaoliu_a.png' },
      { title: '知识加油站', img: '/image/service/b_jiayou.png', aimg: '/image/service/b_jiayou_a.png' },
    ],
    nav: [{ name: '我要预约', url: '/subPackage/pages/appointment/appointment', img: '/image/home/yuyue.png' },
    {
      name: '预约记录', url: '/subPackage/pages/record/record', img: '/image/home/yuyuejiluchaxun-lan.png'
    }],
    sourceList: [
      { title: '朱永新：教育的减法，让孩子更幸福', img: '/image/service/wenzhang.jpg', url: '/subPackage/pages/article/article', id: '1' },
      { title: '教育部举行教育家精神2024年巡回宣讲活动启动仪式暨首场报告会', img: '/image/service/zj_2.jpg', url: '', id: '' },
      { title: '教育部点赞！重庆市“三个三”推动县域义务教育优质均衡发展督导评估', img: '/image/service/zj_3.jpg', url: '', id: '' },
    ],
    nsourceList: [
      { title: '王蔷教授｜ 新课标视域下的单元测试', img: '/image/service/n_0.jpg', url: '', id: '' },
      { title: '【视点】靳彤｜语文教学以“读书”为要——与《为语文的教育还是为教育的语文》作者商榷', img: '/image/service/n_1.jpg', url: '', id: '' },
      { title: '合集丨12种经典教育教学理论（上篇）', img: '/image/service/n_2.jpg', url: '', id: '' },
      { title: '新课标学科实践的内涵理解、思维指向和行动路径', img: '/image/service/n_3.jpg', url: '', id: '' },
    ],
    navs: [{ name: '我要提问', url: '/subPackage/pages/question/index' }, { name: '我来回答', url: '/subPackage/pages/answer/index' }],
    cellList: [
      { title: '刚刚  来自重庆的王老师回复了贵州李老师的提问' },
      { title: '刚刚  来自山东的王老师回复了贵州李老师的提问' },
      { title: '刚刚  来自上海的王老师回复了贵州李老师的提问' },
      { title: '刚刚  来自北京的王老师回复了贵州李老师的提问' },
      { title: '刚刚  来自山西的王老师回复了贵州李老师的提问' },
      { title: '刚刚  来自广州的王老师回复了贵州李老师的提问' },
      { title: '刚刚  来自台湾的王老师回复了贵州李老师的提问' },
      { title: '刚刚  来自江西的王老师回复了贵州李老师的提问' },
    ],
    threenav: [
      { name: '校本资源开发', img: '/image/service/n_xiaobenziyuan.png' },
      { name: '专业知识补给', img: '/image/service/n_baogaoxiangqingzhuanyezhishi.png' },
    ],
    list: [
      { name: '项目简介', img: '/image/service/n_xiangmujianjie.png' },
      { name: '开发流程', img: '/image/service/n_flow-line.png' },
    ],
  },
  onLoad() {
    this.getRestHeight()
  },
  onShow() {

  },
  // 滚动
  getRestHeight() {
    getHeight(this, ['.tOne'], (data) => {
      let { screeHeight, res } = data
      console.log(screeHeight, res);
      this.setData({
        contentH: screeHeight - res[0].top - res[0].height, //内容滚动高度
      })
      // console.log('contentH', this.data, screeHeight, res);
    })
  },
  onScroll(e) {
    const { navTopH } = this.data
    var scrollTop = e.detail.scrollTop
    if ((scrollTop >= navTopH)) {
      if (this.data.isFixed) return
      this.setData({
        isFixed: true
      })
    } else {
      if (!this.data.isFixed) return
      this.setData({
        isFixed: false
      })
    }
  },
  go(e) {
    let { url, id } = e.currentTarget.dataset
    url = id ? url + `?id=${id}` : url;
    wx.navigateTo({
      url: url,
    })
  },
  navClick(e) {
    let { item } = e.currentTarget.dataset
    let oneList = this.data.oneList
    oneList.forEach(i => {
      i.active = false;
      if (item.title === i.title) {
        i.active = true
      }
    })
    this.setData({
      oneList
    })
  }
});
